/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

/**
 *
 * @author A0077454
 */
@Entity
public class PaymentTerm implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long paymentTermId;
    private String termName;
    private String termDesc;
    private Integer discountDay;
    private Double discountAmount;
    private String discountType;
    private Integer creditDay;

    public PaymentTerm(){}
    
    public void create(String termDesc, String termName, Integer discountDay, Double discountAmount, String discountType, Integer creditDay) {
        this.termDesc = termDesc;
        this.termName = termName;
        this.creditDay = creditDay;
        this.discountAmount = discountAmount;
        this.discountDay = discountDay;
        this.discountType = discountType;
    }

    public String getTermName() {
        return termName;
    }

    public void setTermName(String termName) {
        this.termName = termName;
    }
    
    
    public Long getPaymentTermId() {
        return paymentTermId;
    }

    public void setPaymentTermId(Long paymentTermId) {
        this.paymentTermId = paymentTermId;
    }

    public String getTermDesc() {
        return termDesc;
    }

    public void setTermDesc(String termDesc) {
        this.termDesc = termDesc;
    }

    public Integer getCreditDay() {
        return creditDay;
    }

    public void setCreditDay(Integer creditDay) {
        this.creditDay = creditDay;
    }

    public Double getDiscountAmount() {
        return discountAmount;
    }

    public void setDiscountAmount(Double discountAmount) {
        this.discountAmount = discountAmount;
    }

    public Integer getDiscountDay() {
        return discountDay;
    }

    public void setDiscountDay(Integer discountDay) {
        this.discountDay = discountDay;
    }

    public String getDiscountType() {
        return discountType;
    }

    public void setDiscountType(String discountType) {
        this.discountType = discountType;
    }
    
    
   

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (paymentTermId != null ? paymentTermId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PaymentTerm)) {
            return false;
        }
        PaymentTerm other = (PaymentTerm) object;
        if ((this.paymentTermId == null && other.paymentTermId != null) || (this.paymentTermId != null && !this.paymentTermId.equals(other.paymentTermId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.PaymentTerm[ id=" + paymentTermId + " ]";
    }
    
    @OneToMany(cascade = {CascadeType.PERSIST}, mappedBy = "paymentTerm")
    private List<Invoice> invoices = new ArrayList<Invoice>();
    
    
     public List<Invoice> getInvoices() {
        return invoices;
    }

    public void setInvoices(List<Invoice> invoices) {
        this.invoices = invoices;
    }
    
    public void addInvoice(Invoice i)
    {
        this.invoices.add(i);
    }
    
}
